package com.msameer.gwttutor.client;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

public class CustomerActivity extends AbstractActivity implements CustomerView.Presenter {

    // Used to obtain views, eventBus, placeController
    // Alternatively, could be injected via GIN
    private ClientFactory clientFactory;
    // Name that will be appended to "Hello,"
    private Integer id;

    public CustomerActivity(CustomerPlace place, ClientFactory clientFactory) {
        this.id = Integer.valueOf(place.getToken());
        this.clientFactory = clientFactory;
    }
    
	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
        CustomerView customerView = clientFactory.getCustomerView();
        customerView.setPresenter(this);
        customerView.setId(id);
        panel.setWidget(customerView.asWidget());
	}

	@Override
	public void goTo(Place place) {
        clientFactory.getPlaceController().goTo(place);		
	}

}
